<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>在线考试系统-登录</title>
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
	<link href="../res/css/style.css" rel="stylesheet">
    <style type="text/css"></style>
</head>
<body>
<div class="header">
	<div class="container">
		<div class="webTitle pull-left"><a href="#">在线考试系统</a></div>
	</div>
</div>
<div class="main">
	<div class="container">
		<div class="col-xs-4  login-froms pull-right">
			<h2>登录</h2>
			<div class="container">
				<div class="form-group">
					<div class="">
						<label>账号：</label>
						<input type="text" class="form-control" name="number" style="width:250px;" placeholder="请输入学号">
					</div>
				</div>
				<div class="form-group">
					<div class="">
						<label>密码：</label>
						<input type="password" class="form-control" name="password" style="width:250px;" placeholder="请输入密码">
					</div>
				</div>
				<div class="form-group">
					<span><input type="radio" checked="true" name="role" value="1"><label>学生</label></span>
					<span><input type="radio" name="role" value="2"><label>老师</label></span>
					<span><input type="radio" name="role" value="3"><label>管理员</label></span>
				</div>
				<button class="btn btn-default" id="reset-btn" style="width:80px;margin-left:15px;" type="reset">重置</button>
				<button class="btn btn-default" id="submit-btn" style="width:80px;margin-left:87px;" type="submit">登录</button>
			</div>
		</div>
	</div>
</div>
<div class="footer">
	<p>Copyright By Yinrong</p>
</div>

<script src="/res/js/jquery.min.js"></script>
<script src="/bootstrap/js/bootstrap.min.js"></script>
<script src="/res/js/toast.js"></script>
<script>
$(function(){
    $('#reset-btn').click(function() {
        $('[name=number]').val('');
        $('[name=password]').val('');
        $('[name=role]').val('');
    });

    $('#submit-btn').click(function() {
        var number = $('[name=number]').val();
        var password = $('[name=password]').val();
        var role = $('[name=role]').val();
        if(number == undefined ||number == '') {
            new Toast({context:$('body'),top:200 ,time:2000, message:'请填写学号'}).error();
            return false;
        }
        if(password == undefined || password == '') {
            new Toast({context:$('body'),top:200 ,time:2000, message:'请填写密码'}).error();
        }
        if(role == undefined || role == '') {
            new Toast({context:$('body'),top:200 ,time:2000, message:'请选择角色'}).error();
        }
        $.post('/login/execLogin',{"number":number, "password":password,"role":role}, function(ret) {
            if(ret.en == 200) {
                new Toast({context:$('body'),top:200 ,time:2000 ,message:'登录成功'}).success();
                setTimeout(function(){
                    window.location.href = '/';
                } , 1000);
            } else {
                new Toast({context:$('body'),top:200 ,time:2000, message:ret.em}).error();
            }
        });
    });
});
</script>
</body>
</html>